package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.basedoc.model.RoomType;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.travel.model.CheckInImplement.CheckStatus;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;
import java.util.Set;

/**
 * 散客预约房型
 * 
 * @author zhoulin
 *
 */
@Entity
@Table(name = "travel_signuproom")
@Indexed
public class SignUpRoom extends BaseModel {

	private static final long serialVersionUID = -2635675056465124991L;

	@Id
	@In
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	private Long pkSignUpRoom;

	/** 房型 */
	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
	@JoinColumn(name = "pkRoomType")
	@IndexedEmbedded(depth = 1)
	private RoomType roomType;
	
	/** 数量 */
	@Column
	@Field
	private Integer count;

	/** 预订价 */
	@Column
	@Field
	private Double payables;

	/** 房间落实状态 */
	@Enumerated(EnumType.STRING)
	@Field
	@FieldBridge(impl = EnumBridge.class)
	private CheckStatus roomStatus;

	@Version
	private Integer version;
	
	/** 入住价说明 */
	@Column
	private String checkInPriceMark;
	
	@Enumerated(EnumType.STRING)
	@Field
	@FieldBridge(impl = EnumBridge.class)
	@In
	private PriceType priceType;
	
	
	@JsonSerialize(using = EnumSerializer.class)
	public static enum PriceType {
		vipPrice("会员价"), standardPrice("标准价"), protocolPrice("协议价");

		private String display;

		PriceType(String display) {
			this.display = display;
		}

		public String getDisplay() {
			return display;
		}
	}
	
	/** 预约房价信息 */
	@OneToMany
	@JoinColumn(name = "pkSignUpRoom")
	@IndexedEmbedded(depth = 1)
	private Set<SignUpRoomPrice> signUpRoomPrices;

	/** 备注*/
	private String descript;
	
	public Long getPkSignUpRoom() {
		return pkSignUpRoom;
	}

	public void setPkSignUpRoom(Long pkSignUpRoom) {
		this.pkSignUpRoom = pkSignUpRoom;
	}

	public RoomType getRoomType() {
		return roomType;
	}

	public void setRoomType(RoomType roomType) {
		this.roomType = roomType;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public Double getPayables() {
		return payables;
	}

	public void setPayables(Double payables) {
		this.payables = payables;
	}

	public CheckStatus getRoomStatus() {
		return roomStatus;
	}

	public void setRoomStatus(CheckStatus roomStatus) {
		this.roomStatus = roomStatus;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Set<SignUpRoomPrice> getSignUpRoomPrices() {
		return signUpRoomPrices;
	}

	public void setSignUpRoomPrices(Set<SignUpRoomPrice> signUpRoomPrices) {
		this.signUpRoomPrices = signUpRoomPrices;
	}

	public String getCheckInPriceMark() {
		return checkInPriceMark;
	}

	public void setCheckInPriceMark(String checkInPriceMark) {
		this.checkInPriceMark = checkInPriceMark;
	}

	public PriceType getPriceType() {
		return priceType;
	}

	public void setPriceType(PriceType priceType) {
		this.priceType = priceType;
	}

	public String getDescript() {
		return descript;
	}

	public void setDescript(String descript) {
		this.descript = descript;
	}

	
}
